package com.htjc.uep.center.acct.controller;

import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.htjc.uep.center.acct.mapper.SaExtendedConfigMapper;
import com.htjc.uep.center.acct.mapper.UpAcctSyncLogMapper;
import com.htjc.uep.center.acct.service.IAcctService;
import com.htjc.uep.center.commons.utils.JsonUtil;
import com.htjc.uep.center.commons.utils.StringUtil;
import com.htjc.uep.center.model.acct.request.AcctDateRequest;
import com.htjc.uep.center.model.entity.FTPConfig;
import com.htjc.uep.center.model.entity.SaExtendedConfig;
import com.htjc.uep.center.model.entity.UpAcctSyncLog;
import com.htjc.uep.center.model.enums.ErrorStatus;

@RestController
@RequestMapping("jf_acct/acct")
public class AcctController
{

	private Logger log = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private IAcctService acctService;

	@Autowired
	private UpAcctSyncLogMapper upAcctSyncLogMapper;

	@Autowired
	private SaExtendedConfigMapper saExtendedConfigMapper;

	@RequestMapping("acctData")
	public void getAcctData(@RequestBody String str, HttpServletResponse response)
	{

		try
		{
			log.info("积分对账服务-入参={}", str);
			AcctDateRequest acctRequest = JsonUtil.json2Bean(str, AcctDateRequest.class);

			if (StringUtil.isEmpty(acctRequest.getAccountCode(), acctRequest.getAcctDate(), acctRequest.getMechanismCode(), acctRequest.getSign()))
			{
				log.info("积分对账服务-部分参数为空={}", JsonUtil.getError(ErrorStatus.ERROR_PARAM));
			}

			String mechanismCode = acctRequest.getMechanismCode(); //机构编码
			String accountCode = acctRequest.getAccountCode(); //结算编码
			String acctDate = acctRequest.getAcctDate(); //账务日期
			String sign = acctRequest.getSign(); //签名


			acctService.getAcctDate(response, null, acctRequest.getAcctDate(), acctRequest.getAccountCode(), acctRequest.getMechanismCode());
		}
		catch (Exception e)
		{
			log.error("", e);
		}
	}
}
